﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title></title>
    <link href="../../static/css/font.css" rel="stylesheet" />
    <link href="../../static/css/weadmin.css" rel="stylesheet" />
    <link href="../../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../lib/layui/layui.js"></script>
    <style>
       td{color:black;}
    </style>
</head>
<body>
    <div class="weadmin-nav">
        <span class="layui-breadcrumb" style="visibility: visible;">
            <a href="#">首页</a><span lay-separator="">/</span>
            <a href="#">查询统计</a><span lay-separator="">/</span>
            <a><cite>退勤答题记录查询</cite></a>
        </span>
        <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="layui-form">
        <div class="lay-row"></div>
        <div class="layui-inline">
            <label class="layui-form-label">起止日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="TPReleaseStart" />
            </div>
            <div class="layui-input-inline layui-form-label-inner">
                <input type="text" class="layui-input" id="TPReleaseEnd" name="TPReleaseEnd" />
            </div>


            <div class="layui-input-inline">
                <input type="text" class="layui-input" placeholder="工号" id="UserID" />
            </div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" placeholder="姓名" id="UserName" />
            </div>
            <button type="button" class="layui-btn layui-btn-primary" id="find" name="查询"><i class="layui-icon">&#xe615;</i>查询</button>
        </div>
    </div>
    <table id="dataList3" lay-filter="dataList3"></table>
    <script type="text/html" id="zizeng">
        {{d.LAY_TABLE_INDEX+1}}
    </script>
    <script id="barDemo" type="text/html">
        <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="detail">详细</a>
    </script>

    <script>
        var cheduiList = [];
        var currentDeptLevelId = 0;
        var cuurentDeptId = 0; 
 
        layui.use(['form', 'laydate', 'table', 'jquery', 'element', 'layer', 'tree', 'util'], function () {
            var laydate = layui.laydate;
            var $ = layui.jquery
                , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
            var d = new Date();
            var ds = new Date();
            ds = addDate(d, -7);
    
            laydate.render({ elem: '#TPReleaseStart', trigger: 'click', type: 'date', value: ds });
            laydate.render({ elem: '#TPReleaseEnd', trigger: 'click', type: 'date', value: d });
            th = $(document).height() * 0.5;
            tw = $(document).width();

            var table = layui.table;
            var form = layui.form;
            var element = layui.element;
            var layer = layui.layer;
            function showList3() {
                var swhere = JSON.stringify({
                    StartDate: $("#TPReleaseStart").val(),
                    EndDate: $("#TPReleaseEnd").val(), 
                    UserID: $("#UserID").val(),
                    UserName: $("#UserName").val()
                });
                var c = 0;
                table.render({
                    elem: '#dataList3'
                    , url: ApiUrl + 'AttendanceReturnAnswerLog/AttendanceReturnAnswerLogSearch'
                    , totalRow: true
                    , toolbar: true
                    , title: '乘务员答题记录查询'
                    , id: "dataList3"
                    , headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    }
                    , cols: [
                        [
                            { field: 'Row', title: '序号', width: 50 },
                            { field: 'DepName', title: '部门', width: 70 },
                            { field: 'UserID', title: '工号', width: 90 },
                            { field: 'UserName', title: '姓名', width: 80 },
                            { field: 'AnswerDateTime', title: '答题时间', width: 170, sort: true },
                            { field: 'Question', title: '题目', sort: true},
                            { field: 'OptionA', title: '选项A', width: 80 },
                            { field: 'OptionB', title: '选项B', width: 80 },
                            { field: 'OptionC', title: '选项C', width: 80 },
                            { field: 'OptionD', title: '选项D', width: 80 },
                            { field: 'Answer', title: '正确答案', width: 80 },
                            { field: 'AnswerResult', title: '答题结果', width: 80 },
                            {
                                field: 'IsRight', title: '是否正确', width: 100, templet: function (d) {
                                    return d.IsRight ==0 ? "错误" : "正确";
                                }
                            },
                            { field: 'GetValue', title: '得分', width: 80, hide: true },
                        ]
                    ]
                    , where: { swhere: swhere }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表

                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    limit: 50,
                    limits: [10, 30, 50, 100, 150, 200],
                    done: function (res) {
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        if (res.code == 200) {
                            if (res.data != null) {
                                for (var i = 0; i < res.data.length; i++) {
                                    if (res.data[i].IsRight == 0) {

                                        var tr = $('.layui-table-body tbody tr[data-index="' + i + '"]');

                                        //var td = $('.layui-table-body tbody tr[data-index="' + i + '"] td[ data-field="UserID"]')
                                        //td.css('background-color', 'rgb(255,0,0)');
                                        //td.css('color', 'black');

                                        var td = $('.layui-table-body tbody tr[data-index="' + i + '"] td[ data-field="IsRight"]')
                                        td.css('background-color', 'rgb(255,0,0)');
                                        td.css('color', 'black');

                                    }
                                }

                            }
                        }
                    }
                });

            }

            //乘务员 数据结束
             
            $("#find").on("click", function () {
                showList3();//车间数据统计
            }); 

            $(function () {
                showList3();
            })


            function addDate(date, days) {
                var d = new Date(date);
                d.setDate(d.getDate() + days);
                var m = d.getMonth() + 1;
                return d.getFullYear() + '-' + m + '-' + d.getDate();
            }
        });
    </script>
</body>
</html>    